package com.zhj.agent.core;

import net.bytebuddy.matcher.ElementMatcher;

/**
 * 自定义的抽象匹配器
 * @param <S>
 */
public abstract class AbstractJunction<S> implements ElementMatcher.Junction<S> {

    /**
     * And
     *
     * @param <U>            parameter
     * @param elementMatcher element matcher
     * @return the junction
     * @since 1.0.0
     */
    @Override
    public <U extends S> Junction<U> and(ElementMatcher<? super U> elementMatcher) {
        return new Conjunction<>(this, elementMatcher);
    }

    /**
     * Or
     *
     * @param <U>            parameter
     * @param elementMatcher element matcher
     * @return the junction
     * @since 1.0.0
     */
    @Override
    public <U extends S> Junction<U> or(ElementMatcher<? super U> elementMatcher) {
        return new Disjunction<>(this, elementMatcher);
    }
}
